﻿namespace NiYo.ParserBuilder.Domain.Hl7.DataTypes
{
    /// <summary>
    /// XON
    /// </summary>
    public class ExtendedCompositeNameAndIdNumberForOrganizations : Hl7DataType
    {
        #region Properties

        /// <summary>
        /// The name of the specified organization
        /// Standard HL7 position: 1
        /// </summary>
        public string OrganizationName { get; set; }

        /// <summary>
        /// A code that represents the type of name i.e., legal name, display name.
        /// Standard HL7 position: 2
        /// </summary>
        public string OrganizationNameTypeCode { get; set; }

        /// <summary>
        /// The unique identifier
        /// Standard HL7 position: 3
        /// </summary>
        public string IdNumber { get; set; }

        /// <summary>
        /// The check digit which is part of the Id
        /// Standard HL7 position: 4
        /// </summary>
        public string CheckDigit { get; set; }

        /// <summary>
        /// Check digit scheme code
        /// Standard HL7 position: 5
        /// </summary>
        public string CodeCheckDigit { get; set; }

        /// <summary>
        /// a unique identifier of the system that creates the data
        /// Standard HL7 position: 6
        /// </summary>
        public HierarchicDesignator AssigningAuthority { get; set; }

        /// <summary>
        /// A code corresponding to the type of identifier
        /// Standard HL7 position: 7
        /// </summary>
        public string IdentifierTypeCode { get; set; }

        /// <summary>
        /// The place or location identifier where the identifier was first assigned to the person
        /// Standard HL7 position: 8
        /// </summary>
        public HierarchicDesignator AssigningFacility { get; set; }

        /// <summary>
        /// In general it provides an indication of the representation provided by the data item.
        /// Standard HL7 position: 9
        /// </summary>
        public string NameRepresentationCode { get; set; }

        #endregion

        /// <summary>
        /// To compare current ExtendedCompositeNameAndIdNumberForOrganizations with another ExtendedCompositeNameAndIdNumberForOrganizations
        /// </summary>
        /// <returns></returns>
        private bool Equals(ExtendedCompositeNameAndIdNumberForOrganizations other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return Equals(other.OrganizationName, OrganizationName) && Equals(other.OrganizationNameTypeCode, OrganizationNameTypeCode) && Equals(other.IdNumber, IdNumber) && Equals(other.CheckDigit, CheckDigit) && Equals(other.CodeCheckDigit, CodeCheckDigit) && Equals(other.AssigningAuthority, AssigningAuthority) && Equals(other.IdentifierTypeCode, IdentifierTypeCode) && Equals(other.AssigningFacility, AssigningFacility) && Equals(other.NameRepresentationCode, NameRepresentationCode);
        }

        /// <summary>
        /// To compare current ExtendedCompositeNameAndIdNumberForOrganizations with another object
        /// </summary>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != typeof(ExtendedCompositeNameAndIdNumberForOrganizations)) return false;
            return Equals((ExtendedCompositeNameAndIdNumberForOrganizations)obj);
        }

        /// <summary>
        /// Used by Equals method to compare objects
        /// </summary>
        /// <returns></returns>
        public override int GetHashCode()
        {
            unchecked
            {
                var result = (OrganizationName != null ? OrganizationName.GetHashCode() : 0);
                result = (result * 397) ^ (OrganizationNameTypeCode != null ? OrganizationNameTypeCode.GetHashCode() : 0);
                result = (result * 397) ^ (IdNumber != null ? IdNumber.GetHashCode() : 0);
                result = (result * 397) ^ (CheckDigit != null ? CheckDigit.GetHashCode() : 0);
                result = (result * 397) ^ (CodeCheckDigit != null ? CodeCheckDigit.GetHashCode() : 0);
                result = (result * 397) ^ (AssigningAuthority != null ? AssigningAuthority.GetHashCode() : 0);
                result = (result * 397) ^ (IdentifierTypeCode != null ? IdentifierTypeCode.GetHashCode() : 0);
                result = (result * 397) ^ (AssigningFacility != null ? AssigningFacility.GetHashCode() : 0);
                result = (result * 397) ^ (NameRepresentationCode != null ? NameRepresentationCode.GetHashCode() : 0);
                return result;
            }
        }
    }
}
